package com.fancy.learncenter.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;
import com.fancy.learncenter.activity.PreviewVideoActivity;
import com.fancy.learncenter.adapter.base.CommonRecycleViewAdapter;
import com.fancy.learncenter.adapter.base.CustomViewHold;
import com.fancy.learncenter.bean.LifeVideoListDataBean;
import com.fancy.learncenter.common.Constant;
import com.superservice.lya.R;

import java.util.ArrayList;

/**
 * Created by hyy on 2018/3/28.
 */

public class YgtVideoAdapter extends CommonRecycleViewAdapter<LifeVideoListDataBean> {
    public YgtVideoAdapter(Context mContext, ArrayList<LifeVideoListDataBean> itemDatas) {
        super(mContext, R.layout.fragment_ygt_video_item, itemDatas);
    }


    @Override
    public void bindView(CustomViewHold customViewHold, final LifeVideoListDataBean item, final int position) {

        TextView title = customViewHold.getView(R.id.title);
        title.setText(item.getTitle());

        SimpleDraweeView simpleDraweeView = customViewHold.getView(R.id.simpleDraweeView);
        simpleDraweeView.setImageURI(item.getCover());

        customViewHold.getRoorView().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mContext.startActivity(new Intent(mContext, PreviewVideoActivity.class)
                        .putExtra(Constant.VIDEO_PATH, item.getSite()));
            }
        });
        customViewHold.getRoorView().setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                if (deleteCallBack != null) {
                    deleteCallBack.deleteCallBack(position, item.getId());
                }
                return true;
            }
        });
//
    }

    private DeleteCallBack deleteCallBack;

    public DeleteCallBack getDeleteCallBack() {
        return deleteCallBack;
    }

    public void setDeleteCallBack(DeleteCallBack deleteCallBack) {
        this.deleteCallBack = deleteCallBack;
    }

    public interface DeleteCallBack {
        abstract void deleteCallBack(int position, String item);
    }
}
